package com.alks.function.controller.chengKong;


import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.chengKong.*;
import com.alks.function.service.chengKong.PcLotHeadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@ApiRestController("/style")
@Api(tags = {"成控部-工厂生产作业-指令资料输入"
        , "成控部-工厂生产作业-外包指令输入"
        , "成控部-工厂生产作业-指令资料审核"})
@Slf4j
public class PcLotHeadController {

    @Autowired
    private PcLotHeadService pcLotHeadService;

    @PostMapping("/getStyleData")
    @ApiOperation(value = "指令明细", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getStyleData(@RequestBody PcLotHeadRequest request) {
        return pcLotHeadService.getStyleDetails(request);
    }

    @PostMapping("/downloadStyleData")
    @ApiOperation(value = "指令明细导出", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public void downloadStyleData(HttpServletResponse response, @RequestBody PcLotHeadRequest request) throws IOException {
        pcLotHeadService.downloadStyleData(response, request);
    }

    @PostMapping("/getStyleSizeData")
    @ApiOperation(value = "指令明细配码", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getStyleSizeData(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStyleSizeData(request);
    }

    @PostMapping("/getStyleSizeData2")
    @ApiOperation(value = "号码明细（指令明细配码）", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getStyleSizeData2(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStyleSizeData2(request);
    }

    @PostMapping("/getPoNumberDetails")
    @ApiOperation(value = "po号码明细", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getPoNumberData(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getPoNumberDetails(request);
    }

    @PostMapping("/getPoNumberSizeData")
    @ApiOperation(value = "po号码明细动态号码", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getPoNumberSizeData(@RequestBody Map<String, String> map) {
        return pcLotHeadService.getPoNumberSizeData(map);
    }

    @WebLogger
    @PostMapping("/getUsageDetails")
    @ApiOperation(value = "指令用量明细", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getUsageDetails(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStyleUsageDetails(request);
    }

    @GetMapping("/getStyleToLastNoDetails")
    @ApiOperation(value = "型体配楦明细", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getStyleToLastNoDetails(@RequestParam String style) {
        return pcLotHeadService.getStyleOfLastNoDetails(style);
    }

    @PostMapping("/getColorBOMInfo")
    @ApiOperation(value = "配色BOM资料", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getColorBOMInfo(@RequestBody PcLotHeadRequest2 request) {
        return pcLotHeadService.getStyleBOMDetails(request);
    }

    @WebLogger
    @PostMapping("/addStyle")
    @ApiOperation(value = "新增指令", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo addStyle(@RequestBody PcLotHeadRequest request) {
        return pcLotHeadService.addStyle(request);
    }

    @WebLogger
    @PostMapping("/getSoleDetails")
    @ApiOperation(value = "各节点生产明细-取大底入货号码明细查询", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getSoleDetails(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getSoleDetails(request);
    }

    @WebLogger
    @PostMapping("/getStitchDetails")
    @ApiOperation(value = "各节点生产明细-取鞋面生产号码明细查询", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getStitchDetails(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStitchDetails(request);
    }

    @WebLogger
    @PostMapping("/getLastDetails")
    @ApiOperation(value = "各节点生产明细-取成型生产号码明细查询", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getLastDetails(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getLastDetails(request);
    }

    @WebLogger
    @PostMapping("/getSoleDetailsAdd")
    @ApiOperation(value = "各节点生产明细-取大底入货号码明细", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getSoleDetailsAdd(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getSoleDetailsAdd(request);
    }

    @WebLogger
    @PostMapping("/getStitchDetailsAdd")
    @ApiOperation(value = "各节点生产明细-取鞋面生产号码明细", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getStitchDetailsAdd(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStitchDetailsAdd(request);
    }

    @WebLogger
    @PostMapping("/getLastDetailsAdd")
    @ApiOperation(value = "各节点生产明细-取成型生产号码明细", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getLastDetailsAdd(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getLastDetailsAdd(request);
    }

    @WebLogger
    @PostMapping("/getLotNoCopy")
    @ApiOperation(value = "指令复制", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getLotNoCopy(@RequestBody LotNo2Request request) {
        return pcLotHeadService.getLotNoCopy(request);
    }

    @WebLogger
    @PostMapping("/getMiddleCode")
    @ApiOperation(value = "计算中间码", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getMiddleCode(@RequestBody List<LotNoRequest> requests) {
        return pcLotHeadService.getMiddleCode(requests);
    }

    @WebLogger
    @PostMapping("/getLotNoCheck/{choose}")
    @ApiOperation(value = "0检核/1取消检核", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getLotNoCheck(@RequestBody List<LotNoRequest> request, @PathVariable("choose") Integer choose) {
        return pcLotHeadService.getLotNoCheck(request, choose);
    }

    @WebLogger
    @PutMapping("/getStyleDetailUpdate")
    @ApiOperation(value = "指令明细修改", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getStyleDetailUpdate(@RequestBody StyleDetailUpdateRequest request) {
        return pcLotHeadService.getStyleDetailUpdate(request);
    }

    @PostMapping("/getPoNumberDetailAdd")
    @ApiOperation(value = "po号码明细新增", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getPoNumberDetailAdd(@RequestBody PoNumberAddRequest request) {
        return pcLotHeadService.getPoNumberDetailAdd(request);
    }

    @PostMapping("/getPoNumberDetailDel")
    @ApiOperation(value = "po号码明细删除", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getPoNumberDetailDel(@RequestBody PoNumberDelRequest request) {
        return pcLotHeadService.getPoNumberDetailDel(request);
    }

    @WebLogger
    @PostMapping("/getUsageGenerate")
    @ApiOperation(value = "生成指令单", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getUsageGenerate(@RequestBody List<LotNo2Request> requests) {
        return pcLotHeadService.getUsageGenerate(requests);
    }

    @PostMapping("/getStyleSizeDataUpdate")
    @ApiOperation(value = "指令明细配码修改", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getStyleSizeDataUpdate(@RequestBody List<PcLotDetailUpdateRequest> requests) {
        return pcLotHeadService.getStyleSizeDataUpdate(requests);
    }

    @GetMapping("/getCondition")
    @ApiOperation(value = "返回数据", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getCondition() {
        return pcLotHeadService.getCondition();
    }

    @PostMapping("/getStyleCondition")
    @ApiOperation(value = "根据型体回显数据", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public ResponseInfo getStyleCondition(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStyleCondition(request);
    }

    @WebLogger
    @PostMapping("/addLotNo")
    @ApiOperation(value = "新增指令", tags = "成控部-工厂生产作业-外包指令输入")
    public ResponseInfo addLotNo(@RequestBody PcLotHeadRequest request) {
        return pcLotHeadService.addLotNo(request);
    }

    @WebLogger
    @PostMapping("/getLotNoCheckUp/{choose}")
    @ApiOperation(value = "0审核/1取消审核", tags = "成控部-工厂生产作业-指令资料审核")
    public ResponseInfo getLotNoCheckUp(@RequestBody List<LotNoCheckRequest> requests, @PathVariable("choose") Integer choose) {
        return pcLotHeadService.getLotNoCheckUp(requests, choose);
    }

    @WebLogger
    @PostMapping("/getStyleDelete")
    @ApiOperation(value = "整单删除", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo getStyleDelete(@RequestBody LotNoRequest request) {
        return pcLotHeadService.getStyleDelete(request);
    }

    @WebLogger
    @PostMapping("/ExportInstructionSheet")
    @ApiOperation(value = "导出指令单", tags = "成控部-工厂生产作业-指令资料输入")
    public void ExportInstructionSheet(@RequestBody LotNoRequest request, HttpServletResponse response) {
        pcLotHeadService.ExportInstructionSheet(request.getLotNo(), request.getFlag(), response);
    }

    @WebLogger
    @PostMapping("/ExportSizeDetail")
    @ApiOperation(value = "导号码明细（含预先补）", tags = "成控部-工厂生产作业-指令资料输入")
    public void ExportSizeDetail(@RequestBody PcLotHeadRequest request, HttpServletResponse response) {
        pcLotHeadService.ExportSizeDetail(request, response);
    }

    @WebLogger
    @PostMapping("/RefreshTheBody")
    @ApiOperation(value = "刷新型体", tags = "成控部-工厂生产作业-指令资料输入")
    public ResponseInfo RefreshTheBody(@RequestBody LotNoRequest request) {
        return pcLotHeadService.RefreshTheBody(request);
    }

    @PostMapping("/exportLotNo")
    @ApiOperation(value = "导出指令", tags = "成控部-工厂生产作业-指令资料输入")
    @WebLogger
    public void exportLotNo(@RequestBody PcLotHeadRequest request,HttpServletResponse response){
         pcLotHeadService.exportLotNo(request,response);
    }
}
